import {Router, Redirect, Route, Switch} from "react-router-dom";
import './App.scss';
import Layout from "@/pages/Layout";
import Login from "@/pages/Login/index";
import history from "@/utils/history";
import Edit from "@/pages/Profile/Edit";
import AuthRoute from "@/components/AuthRoute";
import Article from "@/pages/Article";
import Search from "@/pages/Search";
import Result from "@/pages/Search/Result";
import Chat from "@/pages/Profile/Chat";

function App() {
  return <Router history={history}>
    <div className={'app'}>
      <Switch>
        {/* 重定向*/}
        <Route path={'/'} exact render={() => <Redirect to={'/home/index'}/>}/>
        {/*props里面也是有路由信息的*/}
        {/*  */}
        <Route path={'/home'} component={Layout}/>
        <Route path={'/login'}>
          {/* 不会把路由信息通过props进行传递的*/}
          {/*组件内部想要获取路由信息*/}
          {/**/}
          <Login/>
        </Route>
        <AuthRoute path={"/profile/edit"}>
          <Edit/>
        </AuthRoute>
        <Route path={'/article/:artId'}>
          <Article/>
        </Route>
        {/* 搜索界面的路由配置*/}
        <Route path={'/search'} exact>
          <Search/>
        </Route>
        {/* 搜索结果页面的路由配置*/}
        <Route path={'/search/result'}>
          <Result/>
        </Route>
        <AuthRoute path={'/chat'}>
          <Chat />
        </AuthRoute>
      </Switch>
    </div>
  </Router>
    ;
}

// WithRouter


export default App;
